<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'apps-form',
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
	<?php
	if($flag =='update')
	{
		echo $form->labelEx($model,'category_code');
		$ori_cate = $categories[$model->category_code] ;
		unset($categories[$model->category_code]) ;
		echo $form->dropDownList($model , 'category_code' , $categories ,array('prompt'=> $ori_cate ) ) ;
		echo $form->error($model,'category_id');
	}
	?>
	</div>
	
	<?php /*?>
	<div class="row">
		<?php echo $form->labelEx($model,'category_code'); ?>
		<?php
		    if($flag =='create')
		        echo $form->dropDownList($model , 'category_code' , $categories,array('prompt'=>'请选择') ) ;
		    else if($flag =='update')
		    {
		    	$ori_cate = $categories[$model->category_code] ;
		    	unset($categories[$model->category_code]) ;
		        echo $form->dropDownList($model , 'category_code' , $categories ,array('prompt'=> $ori_cate ) ) ;
		    }
		?>
		<?php echo $form->error($model,'category_id'); ?>
	</div>
	<?php */?>

	<div class="row">
		<?php echo $form->labelEx($model,'app_type'); ?>
		<?php
			if($flag =='create'){
				unset($appsType[array_search('app' , $appsType)]) ;
				echo $form->dropDownList($model , 'app_type' , $appsType ,array('prompt'=>'app') ) ;
			}
			else if($flag =='update'){
				unset($appsType[array_search($model->app_type, $appsType)]) ;
				echo $form->dropDownList($model , 'app_type' , $appsType , array('prompt'=>$model->app_type) ) ;
			}
		?>
		<?php echo $form->error($model,'app_type'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'app_name'); ?>
		<?php echo $form->textField($model,'app_name',array('size'=>60,'maxlength'=>100)); ?>
		<?php echo $form->error($model,'app_name'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'download_count'); ?>
		<?php echo $form->textField($model,'download_count'); ?>
		<?php echo $form->error($model,'download_count'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'icon_src'); ?>
		<?php echo $form->textField($model,'icon_src',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'icon_src'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'img'); ?>
		<?php echo $form->textField($model,'img',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'img'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'install_url'); ?>
		<?php echo $form->textField($model,'install_url',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'install_url'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'platform_type'); ?>
		<?php
			if($flag =='create'){
				unset($appsPlatType[array_search('iphone' , $appsPlatType)]) ;
				echo $form->dropDownList($model , 'platform_type' , $appsPlatType ,array('prompt'=>'iphone') ) ;
			}
			else if($flag =='update'){
				unset($appsPlatType[array_search($model->platform_type, $appsPlatType)]) ;
				echo $form->dropDownList($model , 'platform_type' , $appsPlatType , array('prompt'=>$model->platform_type) ) ;
			}
		?>
		<?php echo $form->error($model,'platform_type'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'original_price'); ?>
		<?php echo $form->textField($model,'original_price'); ?>
		<?php echo $form->error($model,'original_price'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'price'); ?>
		<?php echo $form->textField($model,'price'); ?>
		<?php echo $form->error($model,'price'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'size'); ?>
		<?php echo $form->textField($model,'size'); ?>
		<?php echo $form->error($model,'size'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'score'); ?>
		<?php echo $form->textField($model,'score'); ?>
		<?php echo $form->error($model,'score'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'corporation'); ?>
		<?php echo $form->textField($model,'corporation',array('size'=>60,'maxlength'=>60)); ?>
		<?php echo $form->error($model,'corporation'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'summary'); ?>
		<?php echo $form->textArea($model,'summary',array('rows'=>6, 'cols'=>50)); ?>
		<?php echo $form->error($model,'summary'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'version'); ?>
		<?php echo $form->textField($model,'version',array('size'=>20,'maxlength'=>20)); ?>
		<?php echo $form->error($model,'version'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'status'); ?>
		<?php
			if($flag =='create'){
				unset($cnAppsStatus[array_search('打开' , $cnAppsStatus)]) ;
				echo $form->dropDownList($model , 'status' , $cnAppsStatus ,array('prompt'=>'打开') ) ;
			}
			else if($flag =='update'){
				$ns_str = $cnAppsStatus[$model->status] ;
				unset($cnAppsStatus[array_search($ns_str, $cnAppsStatus)]) ;
				echo $form->dropDownList($model , 'status' , $cnAppsStatus ,array('prompt'=> $ns_str) ) ;
			}
		?>
		<?php echo $form->error($model,'status'); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->